package cn.mn.ac.demo.controller;

import cn.mn.ac.demo.producer.ExampleProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 何福临
 * @date 2022-08-29 20:11
 */
@Slf4j
@RestController
public class SendController {

    @Resource
    private ExampleProducer exampleProducer;

    private String topic="DEV_TEST";

    private String topic2="DEV_DELAY";

    @GetMapping("/send")
    public void send() {
        exampleProducer.sendMsg("hello ons", topic, "dev_test_tag");
    }

    @GetMapping("/send/async")
    public void sendAsync() {
        exampleProducer.sendMsgAsync("hello ons", topic, "dev_test_tag");
    }

    @GetMapping("/send/delay")
    public void sendDelayMsgAsync() {
        exampleProducer.sendDelayMsgAsync("hello ons", topic2, "dev_test_tag", 30);
    }

}
